package com.tensquare.friend.dao;

import com.tensquare.friend.pojo.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * @description
 * @author: xu1
 **/
public interface FriendDao extends JpaRepository<Friend, String> {

    //数据库的字段是userid friendid
    Friend findByUseridAndFriendid(String userid, String friendid);

    @Modifying//增删改 写
    @Query(value = "UPDATE tb_friend SET islike= ? WHERE userid = ? AND friendid = ?", nativeQuery = true)
    void updateIslike(String islike, String userid, String friendid);

    @Modifying//增删改  要写写
    @Query(value = "delete from tb_friend WHERE userid = ? AND friendid = ?", nativeQuery = true)
    void deletefriend(String userid, String friendid);


}
